import { createApp } from "vue";
import App from "./App.vue";
import installCompoment from "@/components";
// 公共样式
import "@/styles/index.scss";
// svg图标  ！不设置的话图标显示不出来
import "virtual:svg-icons-register";
import { setupRouter } from "@/router";

import { setupStore } from "@/store";

import VConsole from "vconsole";

import { Lazyload } from "vant";
import {detectDevice} from '@/utils'

import "./permission";

const setupAll = async () => {
  const app = createApp(App);
  // 全局组件
  installCompoment(app);
  // 注册状态管理
  setupStore(app);
  // 注册全局路由
  setupRouter(app);
  console.log(process.env.NODE_ENV);
  const device = detectDevice();
  ["development", "test"] && device !== 'PC' && new VConsole();

  // 动态引入失败 手动引入
  app.use(Lazyload);

  // 以375设计稿 htmlsize为16px  为标准
  // window.addEventListener("resize", () => {
  //   const innerWidth = window.innerWidth;
  //   const htmlDom = document.getElementsByTagName("html")[0];
  //   if (innerWidth >= 750) {
  //     htmlDom.style.fontSize = "16px";
  //   } else {
  //     htmlDom.style.fontSize = 16 + (innerWidth - 375) * 0.0427 + "px";
  //   }
  // });

  app.mount("#app");
};

setupAll();
